package com.lzw.security.controller;

import com.lzw.security.entity.*;
import com.lzw.security.exception.MysqlUpdateException;
import com.lzw.security.exception.TidcNulException;
import com.lzw.security.ov.UserOV;
import com.lzw.security.service.UpdateService;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：冯涛滔
 * @date ：Created in 2020-3-28 22:40
 * @description：修改数据请求控制器
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/update")
public class UpdateController{
    @Autowired
    private UpdateService updateService;
    /**
     * create by: 冯涛滔
     * description: 对种类进行修改
     * create time: 2020-3-28 22:45
     * @params [category] id &&(name || url)
     * @return com.lzw.security.ov.UserOV<java.lang.Integer>
     */
    @ApiOperation("修改一个类别 必填id 可选name和url")
    @CheckId
    @CheckUpdate
    @PutMapping("/category")
    public UserOV<Integer> updateCategory(@RequestBody Category category) throws MysqlUpdateException, TidcNulException {
        return updateService.updateCategory(category);
    }
    @ApiOperation("修改一个商品 必填 id 除了quantity(销售量)都能")
    @CheckId
    @CheckUpdate
    @PutMapping("/commodity")
    public UserOV<Integer> updateCommodity(@RequestBody Commodity commodity) throws TidcNulException {
        return updateService.updateCommodity(commodity);
    }
    @ApiOperation("修改一个秒杀商品 除了id什么都能改")
    @CheckId
    @CheckUpdate
    @PutMapping("/seckill")
    public UserOV<Integer> updateSeckill(@RequestBody Seckill seckill){
        return updateService.updateSeckill(seckill);
    }
    @ApiOperation("修改一个附属品 除了id什么都能改")
    @CheckId
    @CheckUpdate
    @PutMapping("/accessory")
    public UserOV<Integer> updateAccessory(@RequestBody Accessory accessory){
        return updateService.updateAccessory(accessory);
    }
    @ApiOperation("修改一个配料 除了id什么都能改")
    @CheckId
    @CheckUpdate
    @PutMapping("/dosing")
    public UserOV<Integer> updateDosing(@RequestBody Dosing dosing){
        return updateService.updateDosing(dosing);
    }
}
